package comdemo.controller;


import comdemo.pojo.Admin;
import comdemo.pojo.Result;
import comdemo.service.IAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 管理员表 前端控制器
 * </p>
 *
 * @author 沈仁聪
 * @since 2025-08-19
 */
@RestController
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private IAdminService adminService;


    /**
     * <p>
     * 获取所有管理员的信息
     * </p>
     *
     * @author 沈仁聪
     * @since 2025-08-19
     */
    @GetMapping
    public Result getadmin()
    {
        List<Admin> list = adminService.list();
        return Result.success(list);
    }


    /**
     * <p>
     * 修改管理员密码，和手机号的共同的接口
     * </p>
     *
     * @author 沈仁聪
     * @since 2025-08-19
     */
    @PostMapping("/update")
    public Result updatepassword(@RequestBody Admin admin)
    {
        adminService.updateById(admin);
        return Result.success();
    }

}
